package com.zsk.shop.common.constant;

import org.springframework.stereotype.Component;

@Component
public class RedisKeys {

    public static String repeatCommit = "user:cache:";
    public static final String TOKEN = "token:";

    public static class gopUser {
        private static String userCachePrefix = "gop:user:";

        ///根据用户ID获取用户缓存KEY
        public static String getHashKey(String token) {
            return userCachePrefix + TOKEN + token;
        }
    }

    //APP用户相关缓存key
    public static class appUser {
        private static String userCachePrefix = "app:user:";

        ///根据用户ID获取用户缓存KEY
        public static String getHashKey(String token) {
            return userCachePrefix + TOKEN + token;
        }

        //存放在webSocketMap中的key,可找到用户所有连接session集合
        public static String getSocketMapKey(String userNo) {
            return userCachePrefix + "userNo->" + userNo + ":socketInfo:";
        }

        //存放在redis中的key,可通过用户的session，找到对应的用户，完成相关操作
        public static String getSocketRedisKey(String sessionId) {
            return userCachePrefix + "socket->sessionId:" + sessionId;
        }

    }

    public static class touristUser {
        private static String userCachePrefix = "tourist:user:";

        ///根据用户ID获取用户缓存KEY
        public static String getHashKey(String token) {
            return userCachePrefix + TOKEN + token;
        }
    }

    /**
     *   数据字典存储KEY
      */
    public static String dictionary = "data:dictionary:";
    public static String dictionaryKey(String key){
        return dictionary + key;
    }

}
